import { defHttp } from '/@/utils/http/axios';
import { BlogItem, TagItem, TypeItem } from '/@/api/blog/model/blogModel';

enum Api {
  findBlogList = '/inyaa-admin/blog/list',
  saveBlog = '/inyaa-admin/blog/save',
  deleteBlog = '/inyaa-admin/blog/delete',
  getBlogInfo = '/inyaa-admin/blog/info',

  findTypeList = '/inyaa-admin/type/list',
  saveType = '/inyaa-admin/type/save',
  deleteType = '/inyaa-admin/type/delete',

  findTagList = '/inyaa-admin/tag/list',
  saveTag = '/inyaa-admin/tag/save',
  deleteTag = '/inyaa-admin/tag/delete',
}

export function findBlogList() {
  return defHttp.get<BlogItem>({ url: Api.findBlogList });
}

export function saveBlog(blog: BlogItem) {
  return defHttp.post<BlogItem>({ url: Api.saveBlog, params: blog });
}

export function deleteBlog(blog: BlogItem) {
  return defHttp.post<BlogItem>({ url: Api.deleteBlog, params: blog });
}

export function getBlogInfo(id: number) {
  return defHttp.get<BlogItem>({ url: Api.getBlogInfo, params: { id: id } });
}

export function findTypeList() {
  return defHttp.get<TypeItem>({ url: Api.findTypeList });
}

export function saveType(blog: TypeItem) {
  return defHttp.post<TypeItem>({ url: Api.saveType, params: blog });
}

export function deleteType(blog: TypeItem) {
  return defHttp.post<TypeItem>({ url: Api.deleteType, params: blog });
}

export function findTagList() {
  return defHttp.get<TagItem>({ url: Api.findTagList });
}

export function saveTag(blog: TagItem) {
  return defHttp.post<TagItem>({ url: Api.saveTag, params: blog });
}

export function deleteTag(blog: TagItem) {
  return defHttp.post<TagItem>({ url: Api.deleteTag, params: blog });
}
